/**
    Copyright (c) 2010 yakiimo02
    Distributed under the New BSD License.
    See included license.txt or http://www.yakiimo3d.com/NewBSDLicense.txt
**/

/**
    @file   
    @brief   Draw the powerplant sdkmesh.
    @author  yakiimo02
    @date    2010/09/26
*/

cbuffer cb0
{
    float4 g_f3EyePt                      : packoffset( c0 );        // Camera position
    matrix g_f4x4World                    : packoffset( c1 );        // World matrix for object
    matrix g_f4x4View                     : packoffset( c5 );        // View matrix
    matrix g_f4x4WorldViewProjection      : packoffset( c9 );        // World * View * Projection matrix
}

struct VS_Input
{
    float3 vPosition      : POSITION;
    float3 vNormal        : NORMAL;
    float2 vTexCoord      : TEXCOORD0;
};

struct PS_Input
{
    float4 vPosition      : SV_Position;
    float3 vNormal        : NORMAL; 
    float2 vTexCoord      : TEXCOORD0;
};

Texture2D    g_txDiffuse     : register( t0 );
SamplerState g_samplerLinear : register( s0 );

/**
*/
PS_Input VS_Main( VS_Input input )
{
    PS_Input O;
    
    O.vPosition = mul( float4( input.vPosition, 1.0f ), g_f4x4WorldViewProjection );
    O.vNormal = normalize( mul( input.vNormal, (float3x3)g_f4x4World ) );
    O.vTexCoord = input.vTexCoord;
        
    return O;
}

/**
*/
float4 PS_Main( PS_Input input ) : SV_TARGET
{
    float4 result;
    result = g_txDiffuse.Sample( g_samplerLinear, input.vTexCoord.xy );
    // Increase the contrast so that antialiased edges are more obvious.
    result = result * 3.0f;
    result.w = 1.0f;
    return result;    
}